package com.hanyxx.io;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

/**
 * @author layman
 * @date 2021/3/14
 */
public class Demo11 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("hero.txt"));
        // 读取对象
        Object object = ois.readObject();
        Hero hero = null;
        if(object instanceof Hero){
            hero = (Hero)object;
        }
        System.out.println(hero);

    }
}
